package com.tem.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tem.system.entity.SystemLevelType;
import com.api.manage.pojo.system.SystemLevelTypeBean;
import com.tem.system.mapper.SystemLevelTypeMapper;
import com.tem.system.service.ISysTypePermissionService;
import com.tem.system.service.ISystemLevelTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.awt.geom.QuadCurve2D;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 系统等级分类 服务实现类
 * </p>
 *
 * @author 腾木
 * @since 2023-11-14
 */
@Service
public class SystemLevelTypeServiceImpl extends ServiceImpl<SystemLevelTypeMapper, SystemLevelType> implements ISystemLevelTypeService {
    @Autowired
    private ISysTypePermissionService sysTypePermissionService;
    public List<SystemLevelTypeBean> getListBeanVsPermission(Long systemLevelId){
        QueryWrapper<SystemLevelType> wrapper = new QueryWrapper();
        wrapper.lambda().eq(SystemLevelType::getSystemLevelId,systemLevelId);
        List<SystemLevelType> list = this.list(wrapper);
        List<SystemLevelTypeBean> beans = new ArrayList<>();
        SystemLevelTypeBean bean=null;
        for(SystemLevelType t:list){
            bean = new SystemLevelTypeBean();
            BeanUtils.copyProperties(t,bean);
            bean.setSysTypePermissions(sysTypePermissionService.getListBean(t.getSystemLevelTypeId()));
            beans.add(bean);
        }
        return beans;
    }
}
